package com.k3cloud.service.impl;

import com.hustcad.plm.pdm.iba.mapper.TyplmStringValueMapper;
import com.k3cloud.mapper.ErpK3cloudMapper;
import com.k3cloud.service.ErpK3cloudService;
import com.ty.basic.entity.attribute.StringValueDO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.math.BigInteger;
import java.util.List;
import java.util.Map;

@Service
public class ErpK3cloudServiceImpl implements ErpK3cloudService {
    @Autowired
    ErpK3cloudMapper erpK3cloudMapper;
    @Autowired
    TyplmStringValueMapper typlmStringValueMapper;


    @Override
    public List<Map<String, Object>> getOptions(String code, String k3cloud) {
        return erpK3cloudMapper.getOptions(code, k3cloud);
    }

    @Override
    public List<Map<String, Object>> getOptionsByPlmCodeAndK3cloudFormId(String plmCode, String k3cloudFormId) {
        return erpK3cloudMapper.getOptionsByPlmCodeAndK3cloudFormId(plmCode, k3cloudFormId);
    }

    @Override
    public List<Map<String, Object>> getExecutionType(String code, String k3cloud) {
        return erpK3cloudMapper.getExecutionType(code, k3cloud);
    }

    @Override
    public List<Map<String, Object>> getExecutionTypeByPlmCodeAndK3cloudFormId(String plmCode, String k3cloudFormId) {
        return erpK3cloudMapper.getExecutionTypeByPlmCodeAndK3cloudFormId(plmCode, k3cloudFormId);
    }

    @Override
    public List<Map<String,Object>> getInTreeMap(String code, String k3cloud) {
        return erpK3cloudMapper.getInTreeMap(code, k3cloud);
    }

    @Override
    public List<Map<String, Object>> getInTreeMapByPlmCodeAndK3cloudFormId(String plmCode, String k3cloudFormId) {
        return erpK3cloudMapper.getInTreeMapByPlmCodeAndK3cloudFormId(plmCode, k3cloudFormId);
    }

    @Override
    public List<Map<String, Object>> getOutTreeMap(String code, String k3cloud) {
        return erpK3cloudMapper.getOutTreeMap(code, k3cloud);
    }

    @Override
    public List<Map<String, Object>> getOutTreeMapByPlmCodeAndK3cloudFormId(String plmCode, String k3cloudFormId) {
        return erpK3cloudMapper.getOutTreeMapByPlmCodeAndK3cloudFormId(plmCode, k3cloudFormId);
    }

    @Transactional(propagation = Propagation.REQUIRES_NEW)
    @Override
    public int saveLogs(String plm_code,String erp_code,String id, String plm_data, String erp_result, String plm_setting_object,
                                              String plm_setting_code, String plm_exception) {
        return erpK3cloudMapper.saveLogs(plm_code,erp_code,id, plm_data, erp_result, plm_setting_object, plm_setting_code, plm_exception);
    }



    @Override
    public List<Map<String, Object>> getBaseCode(BigInteger classId) {
        return erpK3cloudMapper.getBaseCode(classId);
    }


    @Transactional(propagation = Propagation.REQUIRES_NEW)
    public int saveErpEntity(StringValueDO stringValueDO) {
        return typlmStringValueMapper.insert(stringValueDO);
    }
}
